import React from 'react';
import logo from './logo.svg';
import './App.css';

class App extends React.Component {
	constructor(props) {
		super(props);

		this.state = {
			title: 'hello App'
		}
	}

	componentDidMount() {
		const self = this
		fetch('https://4fb5b782-7c22-4e6c-bc01-587628b5097e.bspapp.com/http/todo')
			.then(res => res.json())
			.then((r) => {
				console.log(JSON.stringify(r))
				self.setState({
					title: JSON.stringify(r)
				})
			})
	}

	render () {
		return (
		  <div className="App">
		    <header className="App-header">
		      <img src={logo} className="App-logo" alt="logo" />
		      <p>
		        Edit <code>src/App.js</code> and save to reload.
		      </p>
		      <a
		        className="App-link"
		        href="https://reactjs.org"
		        target="_blank"
		        rel="noopener noreferrer"
		      >
		        {this.state.title}
		      </a>
		    </header>
		  </div>
		);
	}
}

export default App;
